package user

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	agentClient "gitee.com/liuxuezhan/ar-platform/rpc-client/agentClient/client"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserRebateSwitchLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 会员管理 - 会员列表 - 领取返佣配置
func NewUserRebateSwitchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserRebateSwitchLogic {
	return &UserRebateSwitchLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserRebateSwitchLogic) UserRebateSwitch(req *types.UserRebateSwitchRequest) (resp *types.UserRebateSwitchResponse, err error) {
	rpcRep := &agentClient.AgentRebatesSettingSwitchRequest{
		AgentId: req.UserId,
		Status:  req.Status,
	}
	_, err = l.svcCtx.AgentRPC.RebatesSwitch(l.ctx, rpcRep)
	if err != nil {
		return nil, err
	}
	resp = &types.UserRebateSwitchResponse{}
	return
}
